<h1>Listing events</h1>
<%if session[:role] == 0 %>
	<table border=1>
	  <tr>
	  <% for column in Event.content_columns %>
	    <th><%= column.human_name %></th>
		<% end %>
		<th colspan="4">Action</th>	
	  </tr>
	<%if session[:role] == 0 %>
		<% for event in @events %>
		  <tr>
		  <td><%=h event.name %></td>
		  <td><%=h event.date %></td>
		   <td><%=h event.place %></td>
		    <td><%=h event.obs %></td>
		   <td><%=h event.fees %>€</td>
		  
		   
		    <td><%= link_to 'Show', :action => 'show', :id => event %></td>
		    <td><%= link_to 'Edit', :action => 'edit', :id => event %></td>
		    <td><%= link_to 'Delete', { :action => 'destroy', :id => event }, :confirm => 'Are you sure?', :method => :post %></td>
			<td><%= link_to 'Enroll', { :action => 'enroll', :id => event }, :method => :post %></td>
			
		  </tr>
		<% end %>
	<% end %>
	
	</table>
	
	<%= link_to 'Previous page', { :page => @event_pages.current.previous } if @event_pages.current.previous %>
	<%= link_to 'Next page', { :page => @event_pages.current.next } if @event_pages.current.next %> 
	
	<br />
	
	<%= link_to 'Add Event', :action => 'new' %>
<%else%>
	<table border=1>
	  <tr>
	  <% for column in Event.content_columns %>
	    <th><%= column.human_name %></th>
		<% end %>
		<!--th>Fees</th-->
		<th>Action</th>	
	  </tr>
	
		<% for event in @events %>
		  <tr>
		  <!--% for column in Event.content_columns %-->
		    <!--td><!--%=h event.send(column.name) %--></td-->
		  <!--% end %-->
		  
		    <!--td>4€</td-->
			<td><%=h event.name %></td>
		  <td><%=h event.date %></td>
		   <td><%=h event.place %></td>
		    <td><%=h event.obs %></td>
		   <td><%=h event.fees %>€</td>
			<td><%= link_to 'Enroll', { :action => 'enroll', :id => event }, :method => :post %></td>
			
		  </tr>
		<% end %>
	
	
	</table>
	
	<%= link_to 'Previous page', { :page => @event_pages.current.previous } if @event_pages.current.previous %>
	<%= link_to 'Next page', { :page => @event_pages.current.next } if @event_pages.current.next %> 
<% end %>
